const mongoose = require("./db");
mongoose.Schema({});
let loginSchema = new mongoose.Schema({
  phon: String,
  pwd: String,
});
let loginModel = mongoose.model("login", loginSchema, "login");
let yzmSchema = new mongoose.Schema({
  yzm: String,
  phone: String,
});
let jiaoSchema = new mongoose.Schema({
  img_url: String,
  sex: String,
  name: String,
  times: String,
  islike: Boolean,
  age: Number,
  souzaidi: String,
  xingzuo: String,
  xueli: String,
  pwd: String,
  phon: String,
  dong_tai: [
    {
      text: String,
      tage: [String],
      img: String,
      zhans: Number,
      latitude: Number,
      longitude: Number,
      address: String,
      is_ding:Boolean,
    },
  ],
});

let jiaoModel = mongoose.model("jiao", jiaoSchema, "jiao");
let yzmModel = mongoose.model("yzm", yzmSchema, "yzm");

let lf_user = new mongoose.Schema({
  username: String,
  friends: [
    {
      friend: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "lf_user",
      }, //朋友的id
      records: [
        {
          sender: String, //发送者,1是自己,2是朋友
          time: Date,
          type: String, //1是文字
          content: String,
        },
      ], //记录
    },
  ],
});
let lf_user_model = mongoose.model("lf_user", lf_user, "lf_user");

const zzshequSchema = mongoose.Schema({
  img_url: String,
  name: String,
  time: Date,
  title: String,
  touxiang: String,
  cate: Array,
  status: Boolean,
  dianzan: Boolean,
  islike: Boolean,
  age: Number,
  suozaidi: String,
  xingzuo: String,
  xueli: String,
  latitude: Number,
  longitude: Number,
});
const zzshequpinglunSchema = mongoose.Schema({
  name: String,
  touxiang: String,
  title: String,
  time: Date,
  p_id: {
    type: mongoose.Types.ObjectId,
    ref: "zzshequ",
  },
});
const zzliwuSchema = mongoose.Schema({
  name: String,
  price: Number,
  shuliang: Number,
});
const zzliwuModel = mongoose.model("zzliwu", zzliwuSchema);
const zzshequpinglunModel = mongoose.model(
  "zzshequpinglun",
  zzshequpinglunSchema
);
const zzshequModel = mongoose.model("zzshequ", zzshequSchema);
module.exports = {
  zzshequModel,
  zzshequpinglunModel,
  lf_user_model,
  zzliwuModel,
  loginModel,
  yzmModel,
  jiaoModel,
};
